<?php
	session_start();
	header("Content-Type: text/html;charset=utf-8");
	$conn = mysqli_connect('8.129.105.38','db_lsp','123456');
	if($conn){
		$select = mysqli_select_db($conn,"db_lsp");		
		if($select){
			if(isset($_POST["register"])){
				
				$user = $_POST["username"];
				$phone =$_POST["phone"];
				$email =$_POST["email"];
				$password = $_POST["password"];
				
					if($user == ""||$password == ""||$phone == ""||$email == ""){
					echo"<script type="."\""."text/javascript"."\"".">"."window.alert"."("."\""."请填写完整！"."\"".")".";"."</script>";
					echo"<script type="."\""."text/javascript"."\"".">"."window.location="."\""."注册_teacher.html"."\""."</script>";
					exit;
				}
				$sql_select = "select teacher_id from t_db_user where teacher_id='$user'";
				mysqli_query($conn,'SET NAMES UTF8');
				$ret = mysqli_query($conn,$sql_select);
				$row = mysqli_fetch_array($ret); 
				$_SESSION[classification]="teacher";
				if(1){
					if($user==$row['teacher_id']){
						echo"<script type="."\""."text/javascript"."\"".">"."window.alert"."("."\""."用户名已存在，请重新注册！"."\"".")".";"."</script>";
						echo"<script type="."\""."text/javascript"."\"".">"."window.location="."\""."注册_teacher.html"."\""."</script>";
					}
					else
						{
						$sql="insert into t_db_user(teacher_id,teacher_pwd,teacher_email,teacher_tel) values('$user','$phone','$email','$password')";
						$ret = mysqli_query($conn,$sql);
						echo"<script type="."\""."text/javascript"."\"".">"."window.alert"."("."\""."注册成功"."\"".")".";"."</script>";
						echo"<script type="."\""."text/javascript"."\"".">"."window.location="."\""."登录_teacher.html"."\""."</script>";
			}
		}
		mysqli_close($conn);
	}else{		
		die('Could not connect:'.mysql_error());
	}	
}
}
 ?>
